<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2024/12/4
  Time: 9:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>Login Page</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f2f2f2;
            padding: 50px;
        }
        .container {
            max-width: 400px;
            margin: 0 auto;
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        h2 {
            text-align: center;
            margin-bottom: 20px;
        }
        .form-group {
            margin-bottom: 20px;
        }
        .form-group label {
            display: block;
            margin-bottom: 5px;
        }
        .form-group input {
            width: 100%;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        .form-group input[type="submit"] {
            background-color: #4CAF50;
            color: #fff;
            cursor: pointer;
        }
        .form-group input[type="submit"]:hover {
            background-color: #45a049;
        }
    </style>
    <script src="js/jquery-3.5.1.js"></script>
    <script type="text/javascript">
        function login(){
            var username = $("#username").val();
            var password = $("#password").val();
            $.ajax({
                url:"/logincheckByJson",
                type:"post",
                data:JSON.stringify({
                    username:username,
                    password:password
                }),
                contentType: "application/json;charset=UTF-8",
                dataType:"json",
                success:(data)=>{
                    if(data!=null){
                        $("#show").html("你输入的用户名是："+data.username+",密码是："+data.password);
                        $(".show").html("你输入的用户名是："+data.username+",密码是："+data.password);
                    }
                }
            })
        }
    </script>
</head>
<body>
<div class="container">
    <h2>Login</h2>
    <form>
        <div class="form-group">
            <label for="username">Username:</label>
            <input type="text" id="username" name="username" required>
        </div>
        <div class="form-group">
            <label for="password">Password:</label>
            <input type="password" id="password" name="password" required>
        </div>
        <div class="form-group">
            <input type="button" value="登录" onclick　　　　　　　　="login()"/>
        </div>
    </form>
    <div class="form-group">
        <a href="${pageContext.request.contextPath}/register.jsp" class="button">注册</a>
    </div>
    <div id="show"></div>
</div>
</body>
</html>
